﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Audio;

namespace DELVE_GAME
{
    enum SOUNDS
    {
        END_TURN,
        GAME_BGM,
        MENU_BGM,
        MENU_CHANGE,
        MENU_SELECT,
        TILE_CLICK,
        BASE_UPGRADE,
    }
    public class SoundManager
    {
        const string directory = "Sounds/";

        List<SoundEffect> sounds;



        public SoundManager(ContentManager cm)
        {
            sounds = new List<SoundEffect>();
            string contentDirectory = "Content/" + directory;
            if (!Directory.Exists(contentDirectory)) Directory.CreateDirectory(contentDirectory);
            foreach (string file in Directory.GetFiles("Content/" + directory))
            {
                string asset = directory + Path.GetFileNameWithoutExtension(file);
                sounds.Add(cm.Load<SoundEffect>(asset));
            }
        }

        public void playSoundEffect(int soundNum)
        {
            SoundEffectInstance soundInstance = getSound(soundNum);
            soundInstance.Play();
        }

        public SoundEffectInstance getSound(int soundNum)
        {
            SoundEffectInstance soundInstance = null;
            if (soundNum >= 0 && soundNum < sounds.Count)
                soundInstance = sounds[soundNum].CreateInstance();
            return soundInstance;
        }

    }
}
